#ifndef PLAYERWIDGET_H
#define PLAYERWIDGET_H

/**
Nectarine Utility Project is a software interface for the web system 'demovibes'
Copyright (C) 2010  Alexandre LAURENT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

website: http://code.google.com/p/nectarine-utility-project/
e-mail: lw.demoscene@gmail.com
**/

#include <QWidget>
#include <phonon/MediaObject>
#include <phonon/AudioOutput>

#include <QString>
#include <QMap>
#include <QIcon>
#include <QColor>

#include <Phonon/SeekSlider>
#include <Phonon/VolumeSlider>
#include <Phonon/EffectWidget>

class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QProgressBar;
class QPushButton;
class QComboBox;
class QGroupBox;
class QCheckBox;

class QResizeEvent;

class PlayerWidget : public QWidget
{
    Q_OBJECT

private:

    QVBoxLayout* pMainGrid;
    QHBoxLayout* pButtonGrid;

    QLabel* pScreenImageLabel;

    QHBoxLayout* pBufferGrid;
    QLabel* pBufferLabel;
    QProgressBar* pBufferProgressBar;

    Phonon::SeekSlider *pProgressionSlider;

    QPushButton* pPlayButton;
    QIcon playIcon;
    QIcon pauseIcon;
    QPushButton* pStopButton;
    Phonon::VolumeSlider *pVolumeSlider;

    QComboBox* pEffectCB;
    QGroupBox* pEffectBox;
    QList<Phonon::Effect*> listPEffects;
    QCheckBox* pEnableCheckBox;
    Phonon::EffectWidget* pEffectWidget;

    bool isPlaying; // or pause

    QColor baseColour;

    Phonon::Path* pAudioPath;

    QImage renderScreen(const QColor& baseColor);

protected:

protected slots:

    void clickedPlayPauseButton(void);
    void clickedStopButton(void);

    void displayEffectWidget(int effectIndex);
    void toogleEffect(bool isEnabled);

signals:

    void tooglePlayPauseStateSignal(void);
    void stopStateSignal(void);

public:
    PlayerWidget(Phonon::MediaObject* const pMediaObject, Phonon::AudioOutput* const pAudioOutput, Phonon::Path* const pAudioPath, QWidget* parent = 0);
    ~PlayerWidget(void);

    void tooglePlayPauseState(void);
    void setStopState(void);

    void updateInfo(const QMap<QString, QString>& metaData, const QString& url);

    const QColor& getBaseColour(void)const { return baseColour; }
    void setBaseColour(const QColor& newBaseColour) { baseColour = newBaseColour; }
};

#endif // PLAYERWIDGET_H
